/**
 * bootstrap datatimepicker plugins
 */
(function() {
	'use strick',
	require.config({
		paths: {
			"bootstrap.imagepicker": "miwawa/1.0.2/js/jquery/imagepicker/0.2.4/js/image-picker"
		},
		shim: {
			"bootstrap.imagepicker": {
				deps : [
				   "jquery", 
				   "css!miwawa/1.0.2/js/jquery/imagepicker/0.2.4/css/image-picker.css"
				],
				exports:"jQuery.fn.imagepicker"
			}
		}
	});
	
	define(['bootstrap.imagepicker'], function(){
		return {
			register:function(elem, options){
				var _opts = jQuery.extend({
					url: "/miwawa/default/file/find.json",
					data: {},
					width: 200,
					show_label: false,
					hide_select: true
				}, options);
		  
				jQuery.ajaxsend({
					url: _opts.url,
					data: _opts.data,
					success: function(files){
						var picker = jQuery(elem);
						picker.empty();
						jQuery.each(files,function(index, file){
							picker.append('<option data-img-src="'+file.url+'" data-img-width="'+_opts.width+'" value="'+file.id+'">'+file.name+'</option>');
						});
						picker.imagepicker(_opts);
					}
				});
			}
		}
	});
	
	 /*<option data-img-src="http://localhost:9090/miwawa/fileupload/miwawa_haya/shops/201604/KCJS_01.png" data-img-width="220" value="1">Cute Kitten 1</option>
	  <option data-img-src="http://localhost:9090/miwawa/fileupload/miwawa_haya/shops/201604/KCJS_01.png" data-img-width="220" value="1">Cute Kitten 1</option>
	  <option data-img-src="http://localhost:9090/miwawa/fileupload/miwawa_haya/shops/201604/KCJS_01.png" data-img-width="220" value="1">Cute Kitten 1</option>
	  <option data-img-src="http://localhost:9090/miwawa/fileupload/miwawa_haya/shops/201604/KCJS_01.png" data-img-width="220" value="1">Cute Kitten 1</option>
	  <option data-img-src="http://localhost:9090/miwawa/fileupload/miwawa_haya/shops/201604/KCJS_01.png" data-img-width="220" value="1">Cute Kitten 1</option>
	  <option data-img-src="http://localhost:9090/miwawa/fileupload/miwawa_haya/shops/201604/KCJS_01.png" data-img-width="220" value="1">Cute Kitten 1</option>
	  <option data-img-src="http://localhost:9090/miwawa/fileupload/miwawa_haya/shops/201604/KCJS_01.png" data-img-width="220" value="1">Cute Kitten 1</option>
	  <option data-img-src="http://localhost:9090/miwawa/fileupload/miwawa_haya/shops/201604/KCJS_01.png" data-img-width="220" value="1">Cute Kitten 1</option>*/
})(this);
